#pragma once
#include "util.hpp"
#include <mutex>

const string configFile="./cloud.conf";

class Config
{
    private:
        Config()
        {
            ReadConfigFile();  
        }
        static Config *_ptr;
        static mutex _mutex;
    private:
        int _hot_time; 
        int _server_port;
        string _server_ip;
        string _download_prefix;
        string _packfile_suffix;
        string _pack_dir;
        string _back_dir;
        string _backup_file;
        bool ReadConfigFile();
    public:
        static Config* GetConfigObj()
        {
            if(_ptr==nullptr)
            {
                _mutex.lock();
                if(_ptr==nullptr)
                {
                    _ptr=new Config();
                }
                _mutex.unlock();
            }
            return _ptr;
        }

        int GetHotTime();
        int GetServerPort();
        string GetServerIp();
        string GetDownloadPrefix();
        string GetPackSuffix();
        string GetPackDir();
        string GetBackDir();
        string GetBackupFile();
};
